package com.auto.api.framework.interceptor.impl;

import com.auto.api.framework.interceptor.AbstractAspect;
import com.auto.api.framework.interceptor.IInterceptor;
import javax.annotation.Resource;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.Ordered;
import org.springframework.core.PriorityOrdered;
import org.springframework.stereotype.Component;

/**
 * @author liangshf
 * @version 创建时间：2019年9月10日
 * 类说明 Controller切面异常日志打印实现
 */
@Aspect
@Component
public class ControllerAspect extends AbstractAspect implements Ordered {
   
    @Override
    @Resource(name ="controllerInterceptor")
    public void setInterceptor(IInterceptor interceptor) {
    	super.setInterceptor(interceptor);
    }
    
    @Pointcut("@within(org.springframework.web.bind.annotation.RestController)")
		public void controllerInterceptor(){

		}

		@AfterThrowing("controllerInterceptor()")
		public void afterThrowControllerMethod(JoinPoint joinPoint) throws Throwable {
			retailInterceptor.interceptor(joinPoint);
		}

		@Override
		public int getOrder() {
		return PriorityOrdered.HIGHEST_PRECEDENCE + 3;
	}

}
